package com.bristua.sms.tencent.controller;

import com.bristua.mall.common.bean.Result;
import com.bristua.mall.common.biz.ValidateCodeBiz;
import com.bristua.mall.common.enums.CommonCode;
import com.bristua.mall.common.utils.HandleResultUtil;
import com.bristua.sms.tencent.SmsUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2019/4/28.
 */
@RestController
@Api(value="获取验证码",tags={"获取验证码"})
public class GetPhoneCodeController {

    @Autowired
    private ValidateCodeBiz validateCodeBiz;

    @Autowired
    private SmsUtil smsUtil;
    @ApiOperation(value="获取验证码")
    @PostMapping(value="/sms/get/cdoe/{phone}")
    public Result getPhoneCode(@PathVariable(value="phone") String phone){
        String code = validateCodeBiz.createCode(phone);
        smsUtil.smsSend(phone,code);
        return HandleResultUtil.commonResult(CommonCode.VALIDATE_CODE_SEND_SUCCESS.getCode(),CommonCode.VALIDATE_CODE_SEND_SUCCESS.getMsg());
    }
}
